<template>
  <div>
    <div class="user_info_wrap">
      <div
        style="
          display: flex;
          width: calc(100% - 40px);
          margin-left: 20px;
          box-shadow: 0px 2px 8px 0px rgba(150, 150, 150, 0.2);
        "
      >
        <div class="avatar_wrap">
          <div class="avatar">
            <img
              :src="userInfo.headUrl != null ? (baseUrl + userInfo.headUrl) : avatar"
              style="width: 100%; height: 100%"
              alt=""
            />
          </div>
        </div>
        <div class="user_info">
          <div class="user_name">
            <div class="name">
              <span style="margin-right: 5px;">{{userInfo.studentName}}</span>
              <i class="iconfont sex_nan" v-if="userInfo.studentSex == 0">&#xe8b3;</i>  
              <i class="iconfont sex_nv" v-else>&#xe8b4;</i>  
            </div>
            <div class="study_status">
              <span class="tag" v-if="userInfo.state == 0">在读学员</span>
              <span class="tag" v-else>离校学员</span>
            </div>
          </div>
          <div class="usr_detail_info">
            <div class="number">学生编号：{{userInfo.studentCode}}</div>
            <div class="birthday">出生日期：{{userInfo.studentBirthday}}</div>
            <div class="fathorMobile">联系电话：{{userInfo.studentMobile}}</div>
            <div class="fathorMobile">联系电话：{{userInfo.studentMobile2}}</div>
            <div class="number">QQ/微信：{{userInfo.studentNumber}}</div>
            <div class="study_school">在读学校：{{userInfo.atSchool}}</div>
            <div class="parentName">家长姓名：{{userInfo.parentName}}</div>
            <div class="address">家庭住址：{{userInfo.studentAddress}}</div>
            <div class="address">创建时间：{{userInfo.createTime}}</div>
            <!-- <div class="card_num">微信公众号标识：{{userInfo.openId}}</div> -->
          </div>
        </div>
      </div>
    </div>
    <div class="records">
      <div class="nav_wrap">
        <template>
          <el-tabs v-model="activeName" @tab-click="handleClick">
            <el-tab-pane label="报读课程" name="course">
              <Course-list ref="CourseList" />
            </el-tab-pane>
            <el-tab-pane label="上课记录" name="records">
              <Course-records ref="CourseRecords" />
            </el-tab-pane>
          </el-tabs>
        </template>
      </div>
    </div>
  </div>
</template>

<script>
import {
  listStudent,
  getStudent,
  getCourseList,
  getCourseRecords,
  delStudent,
  exportStudent,
} from "@/api/school/student";
import CourseList from './model/CourseList.vue'
import CourseRecords from './model/CourseRecords.vue'
import avatar from '@/assets/images/avatar.png'
export default {
  name: "detail",
  components: {CourseList, CourseRecords},
  data() {
    return {
      avatar: avatar,
      activeName: 'course',
      baseUrl: process.env.VUE_APP_BASE_API,
      userInfo: {}
    };
  },
  created() {
    this.getStudentDetail()
  },
  mounted() {
    this.$refs.CourseList.getData()
  },
  methods: {
    handleClick(tab) {
      this.activeName = tab.name
      if (this.activeName == 'course') {
        this.$refs.CourseList.getData()
      } else {
        this.$refs.CourseRecords.getData()
      }
    },
    getStudentDetail() {
      getStudent(this.$route.query.id).then(res => {
        this.userInfo = res.data
      })
    }
  },
};
</script>
<style scoped lang="scss">
@font-face {
  font-family: "iconfont"; /* Project id 1243753 */
  src: url("//at.alicdn.com/t/font_1243753_y4iv3dvk22.woff2?t=1639976952370")
      format("woff2"),
    url("//at.alicdn.com/t/font_1243753_y4iv3dvk22.woff?t=1639976952370")
      format("woff"),
    url("//at.alicdn.com/t/font_1243753_y4iv3dvk22.ttf?t=1639976952370")
      format("truetype");
}
.iconfont {
  font-family: "iconfont" !important;
  font-size: 16px;
  font-style: normal;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
.user_info_wrap {
  display: flex;
  padding: 20px 0px;
  box-sizing: border-box;
  .avatar_wrap {
    width: 120px;
    display: flex;
    justify-content: center;
    .avatar {
      width: 75px;
      height: 75px;
      border-radius: 50%;
      overflow: hidden;
    }
  }
  .user_info {
    flex: 1;
    .user_name {
      height: 75px;
      display: flex;
      margin-bottom: 15px;
      flex-direction: column;
      justify-content: space-evenly;
      .sex_nan {
        font-size: 12px;
        color: rgb(64, 158, 255);
      }
      .sex_nv {
        font-size: 12px;
        color: #FF69B4;
      }
      .study_status {
        .tag {
          display: inline-block;
          border-radius: 4px;
          padding: 2px 8px;
          color: rgb(64, 158, 255);
          font-size: 10px;
          border: 1px solid rgb(64, 158, 255);
        }
      }
    }
    .usr_detail_info {
      display: flex;
      flex-wrap: wrap;
      font-size: 14px;
      color: #737373;
      div {
        width: 31%;
        margin-bottom: 20px;
        margin-right: 30px;
      }
      div:nth-child(3n + 3) {
        margin-right: 0px;
      }
    }
  }
}
.records {
  width: calc(100% - 40px);
  padding: 10px 10px 0px;
  box-sizing: border-box;
  margin-bottom: 20px;
  margin-left: 20px;
  box-shadow: 0px 2px 8px 0px rgba(150, 150, 150, 0.2);
  .nav_wrap {
    margin: 0px 10px;
  }
}
</style>